package com.news.util;

import java.util.List;

/**
 * 分页工具类
 *
 */
public class Page {
	private int pageNum; //当前页面数
	private int pageSize = 10; //每页条数
	private int total; //总记录数
	private int pages; //总页数
	private int offset; //mysql中的起始偏移量
	private int prePage; //上一页
	private int nextPage; //下一页
	private boolean firstPage; //是否为首页
	private boolean lastPage; //是否为末页
	private List data; //当前页数据
	public int getPageNum() {
		return pageNum;
	}
	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getTotal() {
		return total;
	}
	public void setTotal(int total) {
		this.total = total;
	}
	public int getPages() {
		return getTotal()%getPageSize()==0 ? getTotal()/getPageSize() : getTotal()/getPageSize()+1;
	}
	public void setPages(int pages) {
		this.pages = pages;
	}
	public int getOffset() {
		return (getPageNum()-1)*getPageSize();
	}
	public void setOffset(int offset) {
		this.offset = offset;
	}
	public int getPrePage() {
		return getPageNum()-1>=1 ? getPageNum()-1 : 1;
	}
	public void setPrePage(int prePage) {
		this.prePage = prePage;
	}
	public int getNextPage() {
		return getPageNum()+1<=getPages() ? getPageNum()+1 : getPages();
	}
	public void setNextPage(int nextPage) {
		this.nextPage = nextPage;
	}
	public boolean isFirstPage() {
		return getPageNum()==1;
	}
	public void setFirstPage(boolean firstPage) {
		this.firstPage = firstPage;
	}
	public boolean isLastPage() {
		return getPageNum()==getPages();
	}
	public void setLastPage(boolean lastPage) {
		this.lastPage = lastPage;
	}
	public List getData() {
		return data;
	}
	public void setData(List data) {
		this.data = data;
	}
}
